package com.bw.wxy.mvp.view;

import android.graphics.Color;
import android.os.Build;
import android.view.View;

import com.bw.wxy.R;
import com.bw.wxy.handler.TimeHandler;
import com.bw.wxy.mvp.base.view.BaseActivity;
import com.bw.wxy.mvp.contract.SplashContract;
import com.bw.wxy.mvp.di.DaggerISplshComponent;
import com.bw.wxy.mvp.di.ISplshModules;
import com.bw.wxy.mvp.presenter.SplashPresenter;
import com.bw.wxy.thread.TimeThread;

import io.reactivex.plugins.RxJavaPlugins;

public class SlpashActivity extends BaseActivity<SplashPresenter> implements SplashContract.ISplashView, TimeHandler.TimerCallBack {

    @Override
    public int addBarColor() {
        return Color.WHITE;
    }

    @Override
    public View addStatusView() {
        return f(R.id.isplsh_linear);
    }

    @Override
    public int bindLayout() {
        return R.layout.activity_slpash;
    }
    @Override
    public void initView() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            requestPermissions(new String[]{
                    "android.permission.READ_PHONE_STATE",
                    "android.permission.WRITE_EXTERNAL_STORAGE",
                    "android.permission.READ_EXTERNAL_STORAGE"
            },999);
        }

    }

    @Override
    public void initData() {
        p.requestToken();
    }

    @Override
    public void inject() {
        DaggerISplshComponent.builder().iSplshModules(new ISplshModules(this)).build().inject(this);
    }

    @Override
    public void refresh() {
        new TimeThread(new TimeHandler(this::callBack)).start();
    }

    @Override
    public void callBack() {
        startPage(BottomActivity.class);
        finish();
    }
}